﻿using System;
namespace Xtee.Riik.Ee.Xsd.Xtee {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="esindus_paring", Namespace="http://x-tee.riik.ee/xsd/xtee.xsd", Target=typeof(EsindusParing))]
    public class EsindusParingSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IEsindusParing clazz;
        
        public EsindusParingSerializer(IEsindusParing clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("isikukood");
            if (clazz.Isikukood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikukood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikukood");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "isikukood")) {
                goto isikukood;
            }
            else {
                return;
            }
        isikukood:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>esindus_paring>isikukood");
            }
            clazz.Isikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isikukood")).Value;
            goto START;
        }
    }
}
